package card;

import java.util.ArrayList;
import java.util.Collections;


public class PokerGame {
    //创建集合，创建牌盒
    static ArrayList<String> list = new ArrayList<>();

    //将牌的初始化放在静态代码块里，每次都使用这一套牌
    static {
        //准备牌
        //准备花色
        String[] tab = {"♣", "♦", "♥", "♠"};
        //准备点数
        String[] label = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
        //利用增强for遍历花色和点数
        for (String colear : tab) {
            for (String s1 : label) {
                //组合花色和点数
                String plate = colear + s1;
                //把牌放进牌盒
                list.add(plate);
            }
        }
        //给牌盒添加大小王
        list.add("大王");
        list.add("小王");

    }


    //发牌

    public PokerGame() {
        //洗牌
        Collections.shuffle(list);

        //发牌
        ArrayList<String> lord = new ArrayList<>();
        ArrayList<String> plear1 = new ArrayList<>();
        ArrayList<String> plear2 = new ArrayList<>();
        ArrayList<String> plear3 = new ArrayList<>();
        //遍历牌盒
        for (int i = 0; i < list.size(); i++) {
            //拿到每个牌
            String s = list.get(i);
            //将前三张牌当成地主牌
            if (i < 3) {
                lord.add(s);
                continue;
            } else if (i % 3 == 0) {
                plear1.add(s);
            } else if (i % 3 == 1) {
                plear2.add(s);
            } else {
                plear3.add(s);
            }
        }
        //看牌
        seecard("地主", lord);
        seecard("刘国立", plear1);
        seecard("苟宇同", plear2);
        seecard("仝鲁豫", plear3);
    }
    //看牌

    public void seecard(String str, ArrayList<String> list) {
        //打印看牌格式
        System.out.print(str + ": ");
        //遍历牌发在每个人手里的牌
        for (String s : list) {
            System.out.print(s + " ");
        }
        //换行
        System.out.println();
    }
}
